#pragma once

#include "defines.h"
#include "platform/vk/vk_device_context.h"

namespace vkrender
{
    struct Grid
    {
    public:
        struct Vertex
        {
            glm::vec3 pos;
            glm::vec3 color;
            static std::vector<VkVertexInputBindingDescription> getBindingDescriptions();
            static std::vector<VkVertexInputAttributeDescription> getAttributeDescriptions();
        };
    private:
        std::shared_ptr<VulkanDeviceContext> context;
        float stride;
        // x, y, z, w for [-xmax, xmax, -ymax, ymax]
        glm::ivec4 bounds;
        glm::vec3 color;

        VkBuffer vertexBuffer;
        VkDeviceMemory vertexBufferMemory;
        uint32_t vertexCount;
        VkBuffer indexBuffer;
        VkDeviceMemory indexBufferMemory;
        uint32_t indexCount;
    public:
        Grid(const std::shared_ptr<VulkanDeviceContext>& context);
        void bind(VkCommandBuffer commandBuffer) const;
        void draw(VkCommandBuffer commandBuffer) const;
        
    private:
        void createBuffers();
    };
}
